lst = [11, 222, 123, 456, 159]
asc_lst = sorted(lst)
desc_lst = sorted(lst, reverse=True)
print(asc_lst)
print(desc_lst)

# 反向  结果是迭代器对象，需要转换才能看到
lst1 = reversed(lst)
print(lst1)
print(list(lst1))

# zip
x = ['a', 'b', 'c', 'd']
y = [10, 20, 30, 40]
zip_obj = zip(x, y)
# print(type(zip_obj))
# print(list(zip_obj))

#  枚举
enum = enumerate(y, start=1)
print(type(enum))  # <class 'enumerate'>
print(tuple(enum))  # ((1, 10), (2, 20), (3, 30), (4, 40))

# all
lst2 = [1, 23, '', 10]
print(all(lst2))
print(all(lst))

# any
print(any(lst2))

# next
print(next(zip_obj))  # ('a', 10)
print(next(zip_obj))  # ('b', 20)
print(next(zip_obj))  # ('c', 30)


# filter
def fun(n):
    return n % 2 == 1


obj = filter(fun, range(10))
print(list(obj))  # [1, 3, 5, 7, 9]


# map
def upper(m):
    return m.upper()


# map()函数是Python内置函数之一，
# 用于将一个可迭代对象中的每个元素都应用一个指定的函数，并返回一个新的可迭代对象。
lst3 = ['hello', 'world', 'java']
obj2 = map(upper, lst3)
print(list(obj2))
